﻿// Copyright (C) 2009 - 2013 EvTech Project
//
// This program is free software: you can redistribute it and/or modify
// it under the +terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Media;
using System.Drawing;
using System.IO;

namespace Piirto
{
    public class Character
    {
        private Sprite sprite;
        private SoundPlayer winsound;
        private SoundPlayer crashsound;
        private SoundPlayer movesound;
        public bool IsModifable;
        private string imagepath;
        private string defaultWinSound = "./sounds/default_win.wav";
        private string defaultMoveSound = "./sounds/default_move.wav";
        private string defaultCrashSound = "./sounds/default_crash.wav";


        public Character(Image spriteImg, string winsound, string crashsound, string movesound, bool IsModifable=false)
        {
            this.sprite = new Sprite(spriteImg);
            this.winsound = new SoundPlayer();
            this.crashsound = new SoundPlayer();
            this.movesound = new SoundPlayer();
            setWinsound(winsound);
            setCrashsound(crashsound);
            setMovesound(movesound);
            this.IsModifable = IsModifable;
        }

        public Sprite getSprite()
        {
            return sprite;
        }
        public string getImagepath()
        {
            return imagepath;
        }
        public SoundPlayer getWinsound()
        {
            return winsound;
        }
        public SoundPlayer getCrashsound()
        {
            return crashsound;
        }
        public SoundPlayer getMovesound()
        {
            return movesound;
        }

        internal void setImage(Image img)
        {
            this.sprite.setImage(img);
        }
        public void setImagepath(string imagepath)
        {
            this.imagepath = imagepath;
        }


        internal void setWinsound(string winsound)
        {
            if (winsound != null && File.Exists(winsound))
            {
                this.winsound.SoundLocation = winsound;
            }
            else
            {
                this.winsound.SoundLocation = defaultWinSound;
            }
            this.winsound.LoadAsync();
        }

        internal void setCrashsound(string crashsound)
        {
            if (crashsound != null && File.Exists(crashsound))
            {
                this.crashsound.SoundLocation = crashsound;
            }
            else
            {
                this.crashsound.SoundLocation = defaultCrashSound;
            }
            this.crashsound.LoadAsync();
        }

        internal void setMovesound(string movesound)
        {
            if (movesound != null && File.Exists(movesound))
            {
                this.movesound.SoundLocation = movesound;
            }
            else
            {
                this.movesound.SoundLocation = defaultMoveSound;
            }
            this.movesound.LoadAsync();
        }
    }
}
